import requests


class IhrmApi:

    # 封装登录接口
    @classmethod
    def ihrm_login_api(cls, login_body):
        login_url = ""
        login_header = {"Content-Type": "application/json"}
        login_resp = requests.post(url=login_url, headers=login_header, json=login_body)
        return login_resp

    # 封装添加员工接口
    def add_emp_api(self, token, add_emp_body):
        add_emp_url = "http://ihrm2-test.itheima.net/api/sys/user"
        add_emp_header = {"Content-Type": "application/json",
                          "Authorization": token}
        add_emp_resp = requests.put(url=add_emp_url, headers=add_emp_header, json=add_emp_body)
        return add_emp_resp

    # 封装添加查询接口
    def query_emp_api(self, token,emp_id):
        query_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        query_head = {"Authorization": token}
        query_resp = requests.get(url=query_url, headers=query_head)
        return query_resp

    # 封装修改员工接口
    def modify_emp_api(self, token, modify_body,emp_id):
        modify_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        modify_emp_header = {"Content-Type": "application/json",
                             "Authorization": token}
        modify_resp = requests.put(url=modify_url, headers=modify_emp_header, json=modify_body)
        return modify_resp

    # 封装删除员工接口
    def delete_emp_api(self, token,emp_id):
        delete_emp_url = "http://ihrm2-test.itheima.net/api/sys/user/"+emp_id
        delete_head = {"Authorization": token}
        delete_resp = requests.delete(url=delete_emp_url, headers=delete_head)
        return delete_resp


if __name__ == '__main__':
    token = ""
    body = {}
    print(IhrmApi.add_emp_api(token, body))
